package com.maxvision.mybatis.utils;

import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.asymmetric.KeyType;
import cn.hutool.crypto.asymmetric.RSA;

/**
 * Rsa加密算法公钥、私钥
 */
public class RsaUtils {
    private final static String privateKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKTHI3/aOzuMk38l" +
            "KtJn0oXGmxSigZzBqav1CS9J/4NjuUvD5RNDRvPSFYbnRrjEq04jxUBdXHAcPl9h+pETVYPwxg4EQW4cyp7CBwyi8JiPSBm35H" +
            "qp7cx/CbypF0K0hmLP6ugfR6MrNSVnB645s9QlxGNrmXZ4YlrDRiGUP31nAgMBAAECgYAAkQ7gSxxS96p8tuCBYzB6YAX3GaI6" +
            "Ir0FEELAQhzaDwx/pBm2dpyYwB1cgMQZMW1GlGnpEVGnsOgbM8vRnuWRA3kMaXvdK6f9lwS6B7aFs5CRz2/Q3NLxhwIRKxomZc" +
            "OMrGWB8XHCFLMnOlCG1LbEwPth/snnZ5gsW35ghIJjqQJBANKpaMScMVC+hQVoAhyslbi8owU3b37ylUsmGe9HzRz1vOCKIr0R" +
            "dWBfzBjZrxUmLPl1PUPnnp1kWsbFpArOiw8CQQDIPbfXUaWyJ4mdhBB/9WN7efX9gPhq7VY7DUZypIWOFVuX24UH+tEmAnOep" +
            "62wRdx3Y+L6fFk9RmAV3qVZAUgpAkAhE3xhsmyD0wYrzSLXwblYYjXucb/N3OTYAcl8qndoHqVjVA0URpN5aFExbaxx06aoH" +
            "GJcMRfUepdOMmYJVFi9AkEAyDXldfWd3bZog0UDll1Nfa0hBroIKClruZl5YbEcFEdIkFqd9a+TpRR4dB6lrIT9faYy0U65j2m" +
            "pMtStsIN2mQJAH6Vjk28dzsCIy18ZPofFEGnqObeml8TNjb6dVukMMA1bwXy/5oCYCkkPLhYzbmTV72E6LhI8BsL7aHkysHG2tw==";

    private final static String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCkxyN/2js7jJN/JSrSZ9KFxp" +
            "sUooGcwamr9QkvSf+DY7lLw+UTQ0bz0hWG50a4xKtOI8VAXVxwHD5fYfqRE1WD8MYOBEFuHMqewgcMovCYj0gZt+R6qe3Mf" +
            "wm8qRdCtIZiz+roH0ejKzUlZweuObPUJcRja5l2eGJaw0YhlD99ZwIDAQAB";
    private static RSA rsa = new RSA(privateKey, publicKey);

    public static String decrypt(String encryptStr) {
        byte[] decrypt = rsa.decrypt(encryptStr, KeyType.PrivateKey);
        return StrUtil.str(decrypt, CharsetUtil.CHARSET_UTF_8);
    }


}
